var express = require('express');
var app = express();
var mqtt = require('mqtt')

var client = mqtt.connect('mqtt://wy.wcs91.com')
client.on('connect', function () {
  client.subscribe('presence')
})


app.post('/update', function (req, res) {
  client.publish('/docker/ctrl', 'update')
  return res.json({})
});
app.get('/update', function (req, res) {
  client.publish('/docker/ctrl', 'update')
  return res.json({})
});

app.listen(3000, function () {
  console.log('Example app listening on port 3000!');
});